<?php
/**
 * 店铺端登录.
 * User: Liu
 * Date: 2017/3/14
 * Time: 11:12
 */
namespace app\mobile\controller;

use think\Request;
use app\mobile\model\Member as MemberModel;

class Client extends BaseController
{
    /**
     * 登录页面
     */
    public function login()
    {
        if (Request::instance()->isPost()) {
            $data = Request::instance()->param();

            $members = new MemberModel();

            // 获取用户
            $member = $members->where(['username' => $data['username']])->find();

            // 判断用户是否存在
            if (empty($member)) return ['code' => 404, 'message' => '用户不存在'];

            if ($member['password'] == md5(md5($data['password']))) {
                return ['code' => 200, 'message' => '登录成功'];
            }
            return ['code' => 404, 'message' => '密码和账户不匹配'];

        }
        return $this->fetch('');
    }
}